|
Report with two data levels (master-detail) So far we examined reports where only one data-band was presented ("First level data"). That enabled typing data from one DB table. FastReport allows to type reports containing up to six data levels (it is also possible to type more levels via the "subreport" object; this feature will be examined later). In real applications, reports with large data applications are rarely typed. As a rule, they are limited to 1-3 levels. Let us examine the two-leveled report creation process. It will contain data from the DBDEMOS tables: "Customer.db" è "Orders.db." The first table is the list of clients; the second one is the list of orders placed by the clients. The tables contain data of the following type: Customer:
Orders:
As you can see, the second table contains the list of all the orders placed by all companies. To receive the list of orders placed by a particular company, the notes, in which the "CustNo" field contains the number of the chosen company, should be selected in the table. The report constructed on such data will look as follows:
Let us get down to the report creation. Create a new project in Delphi, put two "TTable," one "TDataSource", two "TfrxDBDataSet" and one "TfrxReport" components to the form. Set the components in the following way: Table1: Table2: DataSource1: frxDBDataSet1: frxDBDataSet2: In the report designer, let us connect our data sources in the "Report|Data..." window. Put the "Master data" and "Detail data" bands on the page:
Note that the "Master Data" band must be allocated above the "Detail Data" band! If allocated under, FastReport will inform you about an error occurrence when the report starts. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||